package com.cssw.fyzb.busi.api.live;

import com.cssw.fyzb.busi.service.live.AnchorService;
import com.cssw.fyzb.core.model.dodb.CmfAnchorBlacklist;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 加入黑名单
 * @author wondream
 */
@Function(description = "加入黑名单", parameters = {
        @Parameter(name = "anchorId", type = Type.String, description = "主播ID", required = true),
        @Parameter(name = "userId", type = Type.String, description = "用户ID", required = true)
})
@Component
public class AddAnchorBlacklist implements Action {

    @Autowired
    AnchorService anchorService;

    @Override
    public Response execute(Request request) throws Exception {
        Long anchorId = request.getLong("anchorId");
        Long userId = request.getLong("userId");
        CmfAnchorBlacklist cmfAnchorBlacklist = anchorService.queryAnchorBlacklist(anchorId, userId);
        if(cmfAnchorBlacklist != null){
            return Response.fail("用户已经加入了黑名单");
        }
        Long anchorBlacklistId = anchorService.addAnchorBlacklist(anchorId, userId);
        return Response.success("操作成功");
    }
}
